package com.service.bank.controller;

import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.client.model.pojo.bank.ArBankcard;
import com.client.model.pojo.bank.ArElectronic;
import com.client.model.pojo.user.ArUser;
import com.client.model.vo.common.Result;
import com.service.bank.mapper.ArBankcardMapper;
import com.service.bank.service.ArBankcardService;
import com.service.bank.service.ArElectronicService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * @Author：刘文举
 * @DateTime： 2024/4/2 18:51
 * @PackageName: com.service.bank.controller
 * @ClassName: BankControler
 */
//用户充值
@RestController
@RequestMapping("/airui/api/bank")
public class BankController {





        @Autowired
        private ArBankcardService arBankcardService;

        @Autowired
        private ArElectronicService arElectronicService;

        @Autowired
        private RedisTemplate<String,String> redisTemplate;

        /**
         * 返回当前用户的银行卡信息
         */
        @GetMapping("/findBank")
        @Operation(summary = "获取当前用户信息")
        public Result findBank(@RequestHeader(name = "token") String token) {
            return arBankcardService.findBank(token);
        }

        /**
         * 充值
         * @param
         * @param price
         * @return
         */
        @PostMapping("/savePrice")
        @Operation(summary = "用户充值")
        public Result savePrice(@RequestParam("price") BigDecimal price,
                                @RequestParam("bankCard")String bankCard,
                                @RequestHeader String token) {
            return arBankcardService.savePrice(bankCard,price,token);
        }

        @PostMapping("payFin")
        @Operation(summary =  "购买理财")
        public Result payFin(@RequestParam("price") BigDecimal price,
                            @RequestParam(name = "bankCard",required = false)String bankCard,
                            @RequestParam("id")Long id,
                            @RequestParam(name = "remark")Integer remark,
                            @RequestHeader String token) {
                System.out.println(price);
                System.out.println(bankCard);
                return  arBankcardService.payFin(bankCard,price,token,id,remark);
        }


}
